<?php
namespace app\baseinfo\controller;

class Products extends \app\common\controller\Base {
	protected $modelname='Product';


    /**
     * 支持按产品名字传入关键字keyword进行查找
     *
     *
     * @return <type>
     */

	protected function _index(){
		$condition=[];
		$param=$this->param;

		if (isset($param['serial_number']))
		$condition[]=['serial_number','=',$param['serial_number']];

		if (isset($param['name']))
			$condition[]=['name','like',"%".$param['name']."%"];

		if (isset($param['price']))
			$condition[]=['price','between',$param['price']];

		if (isset($param['submitter_time']))
			$condition[]=['submitter_time','between',$param['submitter_time']];

		if (isset($param['submitter']))
			$condition[]=['submitter_id',"in",model('admin/AdminUser')->where('real_name','like','%'.$param['submitter'].'%')->column('id')];

		if (isset($param['company']))
			$condition[]=['company_id',"in",model('Company')->where('name','like','%'.$param['company'].'%')->column('id')];

		if (isset($param['deleted']))
			$condition[]=['deleted','=',$param['deleted']=='true'?'1':'0'];
    else
      $condition[]=['deleted','=','0'];

		if (isset($param['remark']))
		  $condition[]=['remark','like',"%".$param['remark']."%"];

		return $condition;
	}
}

?>